package y23.Nov;


import javax.sound.midi.*;

class Music{
    Test9 test9 = new Test9();
    public void xxx(Track track) throws Exception {
        int i = 188;        //右手部分
        test9.addNote(track,0,60);//1
        test9.addNote(track,4,60);//1
        test9.addNote(track,8,67);//5
        test9.addNote(track,12,67);//5
        test9.addNote(track,16,69);//6
        test9.addNote(track,20,69);//6
        test9.addNote(track,24,67);//5
        test9.addNote(track,32,65);//4
        test9.addNote(track,36,65);//4
        test9.addNote(track,40,64);//3
        test9.addNote(track,44,64);//3
        test9.addNote(track,48,62);//2
        test9.addNote(track,52,62);//2
        test9.addNote(track,56,60);//1

        test9.addNote(track,64,67);//5
        test9.addNote(track,68,67);//5
        test9.addNote(track,72,65);//4
        test9.addNote(track,76,65);//4
        test9.addNote(track,80,64);//3
        test9.addNote(track,84,64);//3
        test9.addNote(track,88,62);//2
        test9.addNote(track,96,67);//5
        test9.addNote(track,100,67);//5
        test9.addNote(track,104,65);//4
        test9.addNote(track,108,65);//4
        test9.addNote(track,112,64);//3
        test9.addNote(track,116,64);//3
        test9.addNote(track,120,62);//2

        test9.addNote(track,128,60);//1
        test9.addNote(track,132,60);//1
        test9.addNote(track,136,67);//5
        test9.addNote(track,140,67);//5
        test9.addNote(track,144,69);//6
        test9.addNote(track,148,69);//6
        test9.addNote(track,152,67);//5
        test9.addNote(track,160,65);//4
        test9.addNote(track,164,65);//4
        test9.addNote(track,168,64);//3
        test9.addNote(track,172,64);//3
        test9.addNote(track,176,62);//2
        test9.addNote(track,180,62);//2
        test9.addNote(track,184,60);//1

        test9.addNote(track,i,60);//1
        test9.addNote(track,4+i,60);//1
        test9.addNote(track,8+i,67);//5
        test9.addNote(track,12+i,67);//5
        test9.addNote(track,16+i,69);//6
        test9.addNote(track,20+i,69);//6
        test9.addNote(track,24+i,67);//5
        test9.addNote(track,32+i,65);//4
        test9.addNote(track,36+i,65);//4
        test9.addNote(track,40+i,64);//3
        test9.addNote(track,44+i,64);//3
        test9.addNote(track,48+i,62);//2
        test9.addNote(track,52+i,62);//2
        test9.addNote(track,56+i,60);//1

        test9.addNote(track,64+i,67);//5
        test9.addNote(track,68+i,67);//5
        test9.addNote(track,72+i,65);//4
        test9.addNote(track,76+i,65);//4
        test9.addNote(track,80+i,64);//3
        test9.addNote(track,84+i,64);//3
        test9.addNote(track,88+i,62);//2
        test9.addNote(track,96+i,67);//5
        test9.addNote(track,100+i,67);//5
        test9.addNote(track,104+i,65);//4
        test9.addNote(track,108+i,65);//4
        test9.addNote(track,112+i,64);//3
        test9.addNote(track,116+i,64);//3
        test9.addNote(track,120+i,62);//2

        test9.addNote(track,128+i,60);//1
        test9.addNote(track,132+i,60);//1
        test9.addNote(track,136+i,67);//5
        test9.addNote(track,140+i,67);//5
        test9.addNote(track,144+i,69);//6
        test9.addNote(track,148+i,69);//6
        test9.addNote(track,152+i,67);//5
        test9.addNote(track,160+i,65);//4
        test9.addNote(track,164+i,65);//4
        test9.addNote(track,168+i,64);//3
        test9.addNote(track,172+i,64);//3
        test9.addNote(track,176+i,62);//2
        test9.addNote(track,180+i,62);//2
        test9.addNote(track,184+i,60);//1

        test9.addNote(track,70,0);
        test9.addNote(track,0,48);
        test9.addNote(track,4,48);
        test9.addNote(track,8,48);
        test9.addNote(track,12,48);
        test9.addNote(track,16,53);
        test9.addNote(track,20,53);
        test9.addNote(track,24,48);
        test9.addNote(track,28,48);
        test9.addNote(track,32,43);
        test9.addNote(track,36,43);
        test9.addNote(track,32,48);
        test9.addNote(track,36,48);
        test9.addNote(track,40,43);
        test9.addNote(track,44,43);
        test9.addNote(track,48,48);
        test9.addNote(track,52,48);
    }

    public void fzs(Track track) throws Exception{
        test9.addNote(track,0,67);//5
        test9.addNote(track,4,67);//5

        test9.addNote(track,8,65);//4
        test9.addNote(track,12,64);//3
        test9.addNote(track,16,64);//3
        test9.addNote(track,20,62);//2

        test9.addNote(track,24,60);//1
        test9.addNote(track,26,62);//2
        test9.addNote(track,28,64);//3
        test9.addNote(track,30,60);//1
        test9.addNote(track,32,69);//6
        test9.addNote(track,38,69);//6

        test9.addNote(track,40,67);//5
        test9.addNote(track,44,62);//2
        test9.addNote(track,48,60);//1
        test9.addNote(track,52,64);//3

        test9.addNote(track,56,64);//3
        test9.addNote(track,58,60);//1
        test9.addNote(track,60,69);//6
        test9.addNote(track,62,60);//1
        test9.addNote(track,64,62);//2
        test9.addNote(track,66,67);//5
        test9.addNote(track,68,67);//5

        test9.addNote(track,72,65);//4
        test9.addNote(track,76,64);//3
        test9.addNote(track,80,68);//#5
        test9.addNote(track,84,69);//6
        test9.addNote(track,86,70);//7


    }
}

public class Test9 {
    public static void main(String[] args) throws Exception{

        System.out.println("hello world");
        Sequencer sequencer = MidiSystem.getSequencer();
        sequencer.setTempoInBPM(90);
        Sequence sequence = new Sequence(Sequence.PPQ, 4 );
        sequencer.setSequence(sequence);
        Track track = sequence.createTrack();
        Music music = new Music();
        music.xxx(track);
        sequencer.open();
        sequencer.start();

    }
    void addNote(Track track, int tick, int data1) throws Exception{
        ShortMessage shortMessage = new ShortMessage(ShortMessage.NOTE_ON,0,data1,100);
        MidiEvent midiEvent = new MidiEvent(shortMessage,tick);
        track.add(midiEvent);
    }
}
